package com.hitsoysauce.common;

import java.io.IOException;

import sun.misc.BASE64Decoder;     
import sun.misc.BASE64Encoder;     
    
/**   
 * BASE64加密解密   
 */    
public class BASE64     
{     
    
    /**    
     * BASE64解密   
   * @param key          
     * @return          
     * @throws Exception          
     */              
    public static String decryptBASE64(String key)  {               
    	byte[] result = null;
    	
        try {
			 result = new BASE64Decoder().decodeBuffer(key);
		} catch (IOException e) {
			e.printStackTrace();
		}  
        
        return new String(result);
    }               
                  
    /**         
     * BASE64加密   
   * @param key          
     * @return          
     * @throws Exception          
     */              
    public static String encryptBASE64(String key) {               
        return new BASE64Encoder().encodeBuffer(key.getBytes());               
    }       
         
}    
